package com.tarena.csmall.seckill.mapper;

import cn.tedu.mall.pojo.seckill.dto.SeckillStockDTO;
import cn.tedu.mall.pojo.seckill.model.SeckillStockLog;
import cn.tedu.mall.pojo.seckill.vo.SeckillSkuVO;
import java.util.List;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface SeckillSkuMapper {
    @Select("select * from seckill_sku where spu_id=#{id}")
    List<SeckillSkuVO> selectSkusBySpuId(Long id);

    @Update("update seckill_sku set stock=stock-#{quantity} where id=#{skuId} and stock>=#{quantity}")
    int reduceStock(SeckillStockDTO dto);
    @Update("update seckill_sku set stock=stock+#{quantity} where id=#{skuId} and stock>=#{quantity}")
    void incrementStock(SeckillStockLog log);
    @Select("select * from seckill_sku")
    List<SeckillSkuVO> selectAll();
}
